From be28fe2d5805a1231f2ba706fa1cd3580afeef10 Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Sun, 29 Oct 2023 22:21:41 -0700
Subject: refactor(badges): use http methods

---
 src/routes/user/[user]/badges/+page.svelte | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'src/routes/user/[user]/badges/+page.svelte')

diff --git a/src/routes/user/[user]/badges/+page.svelte b/src/routes/user/[user]/badges/+page.svelte
index 649b0de7..d48cad64 100644
--- a/src/routes/user/[user]/badges/+page.svelte
+++ b/src/routes/user/[user]/badges/+page.svelte
@@ -16,7 +16,7 @@
 	onMount(async () => {
 		// socket.on('badges', (message) => (badges = message));
 
-		badges = await (await fetch(`/api/badges/get?id=${(await user(data.username)).id}`)).json();
+		badges = await (await fetch(`/api/badges?id=${(await user(data.username)).id}`)).json();
 
 		if (data.user) {
 			currentUserIdentity = userIdentity(data.user);
@@ -50,11 +50,11 @@
 		}
 
 		fetch(
-			`/api/badges/add?image=${encodeURIComponent(imageURL.value)}&post=${encodeURIComponent(
+			`/api/badges?image=${encodeURIComponent(imageURL.value)}&post=${encodeURIComponent(
 				activityURL.value
 			)}&description=${encodeURIComponent(description.value)}`,
 			{
-				method: 'POST'
+				method: 'PUT'
 			}
 		).then(() => {
 			error = null;
@@ -65,8 +65,8 @@
 	};
 
 	const removeBadge = (badge: Badge) => {
-		fetch(`/api/badges/remove?id=${badge.id}`, {
-			method: 'POST'
+		fetch(`/api/badges?id=${badge.id}`, {
+			method: 'DELETE'
 		}).then(() => {
 			(document.querySelector(`#badge-${badge.id}`) as HTMLAnchorElement).style.display = 'none';
 		});
-- 
cgit v1.2.3

